import pandas as pd
from urllib.request import urlopen
import json
import plotly.express as px
#step 1 load in your data
#this line allows you to open files
with urlopen('https://raw.githubusercontent.com/plotly/datasets/master/geojson-counties-fips.json') as response:
counties = json.load(response)
#this creates a dataframe, df is a naming convention
df = pd.read_csv(r"C:\Users\Christopher\Default_Apps\Downloads\usa_county_wise.csv")
#get comfy with data
df.describe()
#this is important if you want to build models, see later in pre-processing
df.dtypes
#this is good to read the data like any other data table
df.head(5)
#identify and handle missing values
#missing value, many ways and diferent situations require different approaches
#try to replace missing data from source data
#drop missing values
df.dropna(axis=0, inplace = True)
print(df.head(5))
#Replace missing values with an average,
#df.replace() is the function but this data does not need it
#data binning
##group values into bins
##converts numbers into categories
###bins = np.linspace(min(df['price']))
#categorical variables
fig = px.choropleth_mapbox(df, geojson=counties, locations='FIPS', color='Deaths',
color_continuous_scale="RdBu",
range_color=(0, 500),
mapbox_style="carto-positron",
zoom=3, center = {"lat": 37.0902, "lon": -95.7129},
opacity=0.5,
labels={'Confirmed':'confirmed cases'}
)
fig.show()